home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11243 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: neptune.cs.trinity.edu!jhowland
  2. From: jhowland@ariel.cs.trinity.edu (John E. Howland)
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1,comp.lang.apl
  4. Subject: Re: GOTO controversy
  5. Followup-To: comp.lang.misc,comp.lang.c,comp.lang.pl1,comp.lang.apl
  6. Date: 22 Mar 1996 19:54:28 GMT
  7. Organization: Computer Science Department, Trinity University
  8. Message-ID: <4iv0hl$1pg@neptune.cs.trinity.edu>
  9. References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com>
  10. NNTP-Posting-Host: ariel.cs.trinity.edu
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Scott Hawley (shawley@connix.com) wrote:
  14. > What to you think? Loops without using loops?
  15.  
  16. > a loop:
  17.  
  18. > for(i=0;i<10;i++)
  19. > {
  20. >   stuff
  21. > }
  22.  
  23. > Looping with out a loop
  24.  
  25. > no_loop(0,10);
  26.  
  27. > no_loop(int start, int end)
  28. > {
  29. >     if(start != end) {
  30. >         stuff
  31. >         no_loop(start+1,end);
  32. >     }
  33. > }
  34.  
  35. This is how iteration is done in Scheme.  The above example
  36. is tail-recursive.  In such cases, Scheme systems optimize
  37. this to iterative code.
  38.  
  39. > I haven't tested this but you get the idea.
  40.  
  41. --
  42. ________________________________________________________________
  43. John E. Howland        url: http://www.cs.trinity.edu/~jhowland/
  44. Computer Science     email: jhowland@ariel.cs.trinity.edu
  45. Trinity University   voice: (210) 736-7480
  46. 715 Stadium Drive      fax: (210) 736-7477
  47. San Antonio, Texas  78212-7200
  48.